import request from "@/utils/request.ts";
import type { addTutorialData } from "@/type/resource.ts";

enum API {
  // 部位路由
  BASEBODY_URL = '/api/body',

  // 教程路由
  BASETUTORIAL_URL = '/api/tutorial',

  // 课程路由
  BASECOURSE_URL = '/api/course',

  // 广告路由
  BASEADVERTISING_URL = '/api/advert',

  // 竞赛路由
  BASECOMPETE_URL = '/api/compete',
}

// 获取部位列表

export const getBodyListAPI = () => request({
  method: 'GET',
  url: API.BASEBODY_URL
})

// 添加部位
export const addBodyAPI = (data: any) => request({
  method: 'POST',
  url: API.BASEBODY_URL,
  data
})

// 编辑部位
export const editBodyAPI = (id: string, data: any) => request({
  method: 'PUT',
  url: API.BASEBODY_URL + `/${id}`,
  data
})

// 删除部位
export const deleteBodyAPI = (id: string) => request({
  method: 'DELETE',
  url: API.BASEBODY_URL + `/${id}`
})

// 获取教程列表
export const getTutorialAPI = () => request({
  method: 'GET',
  url: API.BASETUTORIAL_URL
})

// 获取部位教程
export const getTutorialBodyAPI = (gender: any, id: string) => request({
  method: 'GET',
  url: API.BASETUTORIAL_URL + `/body?bodyId=${id}&gender=${gender}`
})

// 添加教程
export const addTutorialAPI = (data: addTutorialData) => request({
  method: 'POST',
  url: API.BASETUTORIAL_URL,
  data
})

// 编辑教程
export const putTutorialAPI = (id: string, data: any) => request({
  method: 'PUT',
  url: API.BASETUTORIAL_URL + `/${id}`,
  data
})

// 删除教程
export const deleteTutorialAPI = (id: string) => request({
  method: 'DELETE',
  url: API.BASETUTORIAL_URL + `/${id}`
})

// 获取课程列表
export const getCourseListAPI = (query: any) => request({
  method: 'GET',
  url: API.BASECOURSE_URL + `?type=${query.type}&pager=${query.pager}&limit=${query.limit}`
})

// 添加课程
export const addCourseAPI = (data: any) => request({
  method: 'POST',
  url: API.BASECOURSE_URL,
  data
})

// 编辑课程
export const putCourseAPI = (id: string, data: any) => request({
  method: 'PUT',
  url: API.BASECOURSE_URL + `/${id}`,
  data
})

// 删除课程
export const deleteCourseAPI = (id: string) => request({
  method: 'DELETE',
  url: API.BASECOURSE_URL + `/${id}`
})

// 获取广告列表
export const getAdvertListAPI = () => request({
  method: 'GET',
  url: API.BASEADVERTISING_URL
})

// 添加广告
export const addAdvertAPI = (data: any) => request({
  method: 'POST',
  url: API.BASEADVERTISING_URL,
  data
})

// 编辑广告
export const editAdvertAPI = (id: string, data: any) => request({
  method: 'PUT',
  url: API.BASEADVERTISING_URL + `/${id}`,
  data
})

// 删除广告
export const deleteAdvertAPI = (id: string) => request({
  method: 'DELETE',
  url: API.BASEADVERTISING_URL + `/${id}`
})

// 获取竞赛列表
export const getCompeteAPI = (query: any) => request({
  method: 'GET',
  url: API.BASECOMPETE_URL + `?page=${query.page}&limit=${query.limit}&type=${query.type}`
})

// 添加竞赛
export const postCompeteAPI = (data: any) => request({
  method: 'POST',
  url: API.BASECOMPETE_URL,
  data
})

// 编辑竞赛
export const editCompeteAPI = (id: string, data: any) => request({
  method: 'PUT',
  url: API.BASECOMPETE_URL + `/${id}`,
  data
})

// 删除竞赛
export const deleteCompeteAPI = (id: string) => request({
  method: 'DELETE',
  url: API.BASECOMPETE_URL + `/${id}`,
})

// 录入第一名
export const putOneCompeteAPI = (id: string, data: any) => request({
    method: 'PUT',
  url: `/api/compete/one/${id}`,
  data
})
